﻿using System;
using System.IO;
using System.Xml;
using System.Web;
using System.Collections.Specialized;
using SyCODE.Component.DataFactory;
using SyCODE.Component.Security;
using SyCODE.Component;
using System.Web.Security;

namespace SyCODE.Blog.Topic
{
    /// <summary>
    /// DeleteTopic.aspx 的处理程序
    /// </summary>
    public class Delete : IHttpHandler
    {
        public virtual bool IsReusable
        {
            get
            {
                return true;
            }
        }

        public void ProcessRequest(HttpContext context)
        {
            NameValueCollection nvc = new NameValueCollection(context.Request.Form);

			Ticket ticket = Ticket.Get(FormsAuthentication.FormsCookieName);

            if (Ticket.Authenticate(ticket))
            {
                nvc.Add("u", ticket.Name);

                DBAM dbam = new DBAM();
                dbam.BuildParameters("deletetopic", nvc);

                try
                {
                    if (dbam.Execute() > 0 && (bool)dbam.GetResult())
                    {
                        SyCODE.SearchEngine.Simple.Delete(nvc["id"]);
                    }
                }
                finally
                {
                    dbam.Dispose();
                }
            }
            else
            {
                Function.ClientAlert(StringResource.GetField("authfaild"));
            }
        }
    }
}
